﻿using System;
using System.Collections.Generic;
using System.Text;


using EShop.DAL;
using EShop.Model;
using System.Data;

namespace EShop.BLL
{
    public class MerchandiseSellBLL
    {
        MerchandiseSellDAL oSellDAL = new MerchandiseSellDAL();

         /// <summary>
        /// 取单个上架商品的信息
        /// </summary>
        /// <param name="strBarCode"></param>
        /// <returns></returns>
        public MerchandiseSell GetSigleSellMerchandiseDetail(string strBarCode)
        {
            return oSellDAL.GetSigleSellMerchandiseDetail(strBarCode);
        }


        /// <summary>
        /// 取得库存数据，准备上架
        /// </summary>
        /// <returns></returns>
        public DataTable GetStockToSellData()
        {
            return oSellDAL.GetStockToSellData();
        }

        /// <summary>
        /// 插入上架数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool AddMerchandiseSell(MerchandiseSell model)
        {
            return oSellDAL.AddMerchandiseSell(model);
        }

        /// <summary>
        /// 查询今日所有[指定员工]的销售状况
        /// </summary>
        /// <param name="strEmployeeID">被查询的EmployeeID，如果为null则查询今天所有</param>
        /// <param name="RealAmount"></param>
        /// <param name="sellOrderDetail"></param>
        public void MerchandiseTodaySelled(string strEmployeeID,out decimal RealAmount,out DataTable sellOrderDetail)
        {
            DataSet ds = oSellDAL.MerchandiseTodaySelled(strEmployeeID);
            int i=ds.Tables.Count;
            object o = ds.Tables[0].Rows[0][0];
            DataTable dt = ds.Tables[0];
            int j = dt.Rows.Count;
            string str = ds.Tables[0].Rows[0][0].ToString();
            try
            {
                RealAmount = Convert.ToDecimal(ds.Tables[0].Rows[0][0]);
            }
            catch
            {
                RealAmount = 0m;
            }
            sellOrderDetail = ds.Tables[1];
        }
    }
}
